package com.ud.demobase.lister;
import jakarta.servlet.annotation.WebListener;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpSessionEvent;
import jakarta.servlet.http.HttpSessionListener;

@WebListener
public class OnlineListener implements HttpSessionListener {
    private static int count = 0;
    public static int getcount() { return count;}

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        count++;
        System.out.println("count: " + count);
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        count--;
        System.out.println("count: " + count);
    }
}